package com.kaidi.dibankecloud.activity;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;

import com.kaidi.dibankecloud.R;
import com.kaidi.dibankecloud.databinding.ActivitySplashBinding;
import com.kaidi.dibankecloud.utils.WindowUtils;

public class SplashActivity extends AppCompatActivity {
    private final static int JUMP_PAGE = 1024;
    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if(msg.what == JUMP_PAGE){
                startActivity(new Intent(SplashActivity.this,MainActivity.class));
                finish();
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivitySplashBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_splash);
        //沉浸式状态栏设计
        WindowUtils.setColor(this, Color.WHITE);
        //设置字体
        Typeface appNameTF = Typeface.createFromAsset(getAssets(), "fonts/fzltxhjt.ttf");
        Typeface slogansTF = Typeface.createFromAsset(getAssets(), "fonts/zzgfyy.ttf");
        binding.setAppNameTF(appNameTF);
        binding.setSlogansTF(slogansTF);

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                handler.sendEmptyMessage(JUMP_PAGE);
            }
        }).start();
    }
}
